package net.kong.sns.rest.client.friend.json;

import net.kong.sns.rest.client.ClientTestBase;
import net.kong.sns.rest.client.model.FriendInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;


/**
 * @author yk
 * @version $Id: Friends_Get_Info.java,v 1.5 2009/11/04 13:26:21 ningyubin Exp $
 */
@RunWith(Parameterized.class)
public class Friends_Get_Info extends ClientTestBase {

    private Long friends_get_id;

    private List<FriendInfo> friends_get_info_ret;

    public Friends_Get_Info(String file, Long friends_get_id, List<FriendInfo> friends_get_info_ret) {
        super(Friend_Get_Id.class.getResourceAsStream(file));
        this.friends_get_id = friends_get_id;
        this.friends_get_info_ret = friends_get_info_ret;
    }

    @Parameters
    public static Collection<Object[]> testData() {
        return Arrays.asList(new Object[][]{{"Friends_Get_Info_1.xml", 7L, new ArrayList<FriendInfo>() {

            {
                add(new FriendInfo(111, "test1", true, false));
                add(new FriendInfo(222, "test2", false, true));
            }
        }}});
    }

    //鏈塻essionKey
    @Test
    public void friends_get_info_withSessionKey() {
        List<FriendInfo> ret = client.friends_get_info(friends_get_id);
        Assert.assertEquals(friends_get_info_ret, ret);
        if (friends_get_id != null)
            Assert.assertEquals(friends_get_id.toString(), ((Object[]) parameterMap.get("user_id"))[0]);
        else
            Assert.assertNull(((Object[]) parameterMap.get("user_id")));
        Assert.assertEquals("1", ((Object[]) parameterMap.get("format"))[0]);
        Assert.assertEquals("json", ((String[]) parameterMap.get("response_format"))[0]);
        Assert.assertEquals("1.0", ((String[]) parameterMap.get("v"))[0]);
    }

    //鏃爏essionKey
    @Test
    public void friends_get_info_noSessionKey() {
        List<FriendInfo> ret = client_noSessionKey.friends_get_info(friends_get_id);
        Assert.assertEquals(friends_get_info_ret, ret);
        if (friends_get_id != null)
            Assert.assertEquals(friends_get_id.toString(), ((Object[]) parameterMap.get("user_id"))[0]);
        else
            Assert.assertNull(((Object[]) parameterMap.get("user_id")));
        Assert.assertEquals("1", ((Object[]) parameterMap.get("format"))[0]);
        Assert.assertEquals("json", ((String[]) parameterMap.get("response_format"))[0]);
        Assert.assertEquals("1.0", ((String[]) parameterMap.get("v"))[0]);
    }
}
